package com.ruoyi.task.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.firefighter.domain.FirefighterInfo;
import com.ruoyi.firefighter.service.IFirefighterInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.task.mapper.FirefighterFireTaskMapper;
import com.ruoyi.task.domain.FirefighterFireTask;
import com.ruoyi.task.service.IFirefighterFireTaskService;

/**
 * 重大火灾任务Service业务层处理
 *
 * @author ruoyi
 * @date 2024-10-11
 */
@Service
public class FirefighterFireTaskServiceImpl implements IFirefighterFireTaskService
{
    @Autowired
    private FirefighterFireTaskMapper firefighterFireTaskMapper;
    @Autowired
    private IFirefighterInfoService iFirefighterInfoService;
    /**
     * 查询重大火灾任务
     *
     * @param id 重大火灾任务主键
     * @return 重大火灾任务
     */
    @Override
    public FirefighterFireTask selectFirefighterFireTaskById(Long id)
    {
        return firefighterFireTaskMapper.selectFirefighterFireTaskById(id);
    }

    /**
     * 查询重大火灾任务列表
     *
     * @param firefighterFireTask 重大火灾任务
     * @return 重大火灾任务
     */
    @Override
    public List<FirefighterFireTask> selectFirefighterFireTaskList(FirefighterFireTask firefighterFireTask)
    {
        return firefighterFireTaskMapper.selectFirefighterFireTaskList(firefighterFireTask);
    }

    /**
     * 新增重大火灾任务
     *
     * @param firefighterFireTask 重大火灾任务
     * @return 结果
     */
    @Override
    public int insertFirefighterFireTask(FirefighterFireTask firefighterFireTask)
    {
        FirefighterInfo firefighterInfo1 = new FirefighterInfo();
        firefighterInfo1.setIdCardNumber(firefighterFireTask.getFirefighterIdCard());
        FirefighterInfo firefighterInfo= iFirefighterInfoService.selectFirefighterInfoBySfz(firefighterInfo1);
        if (firefighterInfo==null){
            return 0;
        }
        firefighterFireTask.setFirefighterId(firefighterInfo.getUserId());
        firefighterFireTask.setCreateTime(DateUtils.getNowDate());
        return firefighterFireTaskMapper.insertFirefighterFireTask(firefighterFireTask);
    }

    /**
     * 修改重大火灾任务
     *
     * @param firefighterFireTask 重大火灾任务
     * @return 结果
     */
    @Override
    public int updateFirefighterFireTask(FirefighterFireTask firefighterFireTask)
    {
        firefighterFireTask.setUpdateTime(DateUtils.getNowDate());
        return firefighterFireTaskMapper.updateFirefighterFireTask(firefighterFireTask);
    }

    /**
     * 批量删除重大火灾任务
     *
     * @param ids 需要删除的重大火灾任务主键
     * @return 结果
     */
    @Override
    public int deleteFirefighterFireTaskByIds(Long[] ids)
    {
        return firefighterFireTaskMapper.deleteFirefighterFireTaskByIds(ids);
    }

    /**
     * 删除重大火灾任务信息
     *
     * @param id 重大火灾任务主键
     * @return 结果
     */
    @Override
    public int deleteFirefighterFireTaskById(Long id)
    {
        return firefighterFireTaskMapper.deleteFirefighterFireTaskById(id);
    }

    @Override
    public void deleteFirefighterFireTaskById1(Long userId) {
        firefighterFireTaskMapper.deleteFirefighterFireTaskByIdsuser(userId);
    }
}
